#include "Block.h"

Block::Block(int locx, int locy, int locz,vector<vector<vector<Floor*>>> floor)
{
	collision = false;
	dir = NODIR;
	theFloor = floor;
	x = locx;
	y = locy;
	z = locz;
	type = BLOCK;
	
	removeable = false;
}

Block::~Block(void)
{
}





//When an this object is hit by the collider do certain stuff
void Block::collide(Object* collider)
{
	//assume that collision will be over (if its not it'll flag itself again)
	collision=false;
	dir = collider->getDirection();
	if(collider->getType() == TAIT){
		move(collider->getDirection());
	}

}

//When this object hits another object do certain stuff (ie if its an exit win the game)
void Block::collideWith(Object* collidee){
	//All collisions must end by flagging collision as false
	collision = false;
	if (collidee->getType() == TAIT) {
		collidee->move(dir);
	}
	if (collidee->getType() == BOMB) {
		removeable=true;
		theFloor[x][y][z]->changeObject(NONE);
	}
}
void Block::doFloor(Equip currentEquip){

	condition = FINE;
	//sliding will set you into sliding unless you're against a wall
	if(theFloor[x][y][z] ->getType() == ICE){
		if(!checkCollide()&&bounds()){
		condition = SLIDING;
		move(dir);
		}
	}
	if(theFloor[x][y][z] ->getType() == FIRE){
		theFloor[x][y][z] ->changeState(EXTINGUISHED);
	}
	if(theFloor[x][y][z]->getType() == WATER && theFloor[x][y][z]->getFloorState() == WATERFILLED){
		theFloor[x][y][z] ->changeState(BLOCKFILLED);
		removeable = true;
		theFloor[x][y][z] ->changeObject(NONE);
	}

	if(theFloor[x][y][z] ->getType() == FORCE){
		switch(theFloor[x][y][z] ->getFloorState()){
			case UPFLOOR:
				dir = UP;
				break;
			case DOWNFLOOR:
				dir = DOWN;
				break;
			case RIGHTFLOOR:
				dir = RIGHT;
				break;
			case LEFTFLOOR:
				dir = LEFT;
				break;
		}
		if(!checkCollide()&&bounds()){
			condition = SLIDING;
			switch(theFloor[x][y][z] ->getFloorState()){
			case UPFLOOR:
				move(UP);
				break;
			case RIGHTFLOOR:
				move(RIGHT);
				break;
			case DOWNFLOOR:
				move(DOWN);
				break;
			case LEFTFLOOR:
				move(LEFT);
				break;
			}
		}
	}


}